package com.aspirecn.auth.repository;

import com.aspirecn.auth.domain.SysUser;
import com.aspirecn.auth.repository.support.WiselyRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

import java.util.Optional;

public interface SysUserRepository extends WiselyRepository<SysUser,Long> {
    Optional<SysUser> findOneWithRolesByUsername(String username);

    @Query(value = "update SysUser set password=?1 where username=?2 ", nativeQuery = false)
    @Modifying
    void updatePwd(String newPwd, String username);

    @Query(value = "from SysUser where username=?", nativeQuery = false)
    SysUser findOneByUserName(String username);
}
